// define the namespace
syslib.namespace("syslib.ui");

// tag conversor
syslib.ui.ToolbarTag = __class(syslib.ui.TagConversor, {
	component : null, 

	execute : function(){
		// create the toolbar
		var component = new syslib.ui.Toolbar(this.__attributes);
		
		// append
		component.appendTo(this.__container);
		
		// store the component
		this.component = component;
	},

	getComponent : function(){
		return this.component;
	}
});

// component definition
syslib.ui.Toolbar = __class(syslib.ui.UIComponent, {
	__options : {}, 
	__body : null, 
	
	__construct : function(options){
		// load the style
		syslib.loadStyleForComponent("toolbar");
		
		// format the options
		this.__options = __extend({
			"id" : syslib.element.generateID(),
			"content" : "", 
			"items" : []
		}, options);
	},
	
	__createElement : function(){
		// set the attributes of the element
		var attributes	= { 
			"class" : "syslib-toolbar-container syslib-border syslib-flat-background", 
			"width" : "100%",
			"style" : (__valid(this.__options.style)) ? this.__options.style : ""
		};
		
		// create the json structure
		elemtJSON = ["table", attributes,  
		    ["tbody", 
				["tr", 
					["td", {"valign" : "center", "class" : "syslib-toolbar-cell syslib-text", "innerName" : "body"}, 
						this.__options.content
					] 
				] 
			] 
		];

		// create the element
		var toolbar = syslib.element.createFromJSON(false, elemtJSON);
		
		// set the element
		this.__element 	= toolbar.element;
		this.__body		= toolbar.references.body;
		
		// return
		return this.__element;
	}, 
	
	appendTo : function(container){
		container.appendChild(this.getElement());
	}, 
	
	appendChild : function(child){
		this.__body.appendChild(child);
	}
});